/**
 * api对外文件
 * 内置登录等基础接口
 * 内置自动加载目录下其他文件接口
 */
import request from "@/libs/request";

const apiFiles = import.meta.glob("./*.js", { eager: true });
let apis = {};
for (const path in apiFiles) {
    apis = {
        ...apis,
        ...apiFiles[path].default,
    };
}
export default {
    getCaptcha(data) {
        const API_BASE_URL = import.meta.env.DEV ? "/adminapi" : import.meta.env.VITE_API_BASE_URL || `${location.origin}`;
        return API_BASE_URL + "/adminapi/login/captcha";
    },
    doLogin(data) {
        return request({
            url: `/adminapi/login/login`,
            method: "POST",
            data: data,
        });
    },
    resetPassword(data) {
        return request({
            url: `/adminapi/admin/resetPassword`,
            method: "POST",
            data: data,
        });
    },
    getPermissionList(data) {
        return request({
            url: `/adminapi/admin/getPermissionList`,
            method: "GET",
            data: data,
        });
    },
    getAdminRoleList(data) {
        return request({
            url: `/adminapi/admin/getRoleList`,
            method: "GET",
            data: data,
        });
    },
    getRoleDeatil(data) {
        return request({
            url: `/adminapi/admin/getRoleDeatil`,
            method: "GET",
            data: data,
        });
    },
    saveRoleDeatil(data) {
        return request({
            url: `/adminapi/admin/saveRoleDeatil`,
            method: "POST",
            data: data,
        });
    },
    delRole(data) {
        return request({
            url: `/adminapi/admin/delRole`,
            method: "DELETE",
            data: data,
        });
    },
    getAdminList(data) {
        return request({
            url: `/adminapi/admin/getAdminList`,
            method: "GET",
            data: data,
        });
    },
    saveAdminDeatil(data) {
        return request({
            url: `/adminapi/admin/saveAdminDeatil`,
            method: "POST",
            data: data,
        });
    },
    delAdmin(data) {
        return request({
            url: `/adminapi/admin/delAdmin`,
            method: "DELETE",
            data: data,
        });
    },
    changeGoogleCode(data) {
        return request({
            url: `/adminapi/admin/changeGoogleCode`,
            method: "POST",
            data: data,
        });
    },
    ...apis,
};
